<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="jakarta.faces.html" xmlns:f="jakarta.faces.core"
    xmlns:ui="jakarta.faces.facelets" xmlns:p="http://primefaces.org/ui" template="/template.xhtml"
    xmlns:c="jakarta.tags.core">
    <ui:define name="content">


        <p:dataTable id="defDicts" widgetVar="dictsTable" var="c" value="#{sysParamMB.lazyModel}" rows="10"
            rowKey="#{c.id}" lazy="true" paginator="true" paginatorPosition="bottom"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {JumpToPageDropdown}"
            currentPageReportTemplate="[ {startRecord} to {endRecord} of {totalRecords} ]"
            rowsPerPageTemplate="5,10,20,30,50,100,200,300,500,1000" draggableColumns="true" resizableColumns="true"
            liveResize="true" showGridlines="true" scrollable="true" scrollHeight="660" multiViewState="false"
            selectionMode="multiple" selection="#{sysParamMB.multipleSelected}"
            globalFilterOnly="#{sysParamMB.globalFilterOnly}">
            >
            <!--selectionMode="single" selection="{sysParamMB.singleSelected}"-->
            <f:facet name="header">
                <p:toolbar>
                    <p:toolbarGroup align="left" class="grid">
                        <p:commandButton id="delete-single-button" value="#{sms['button.delSingle']}" icon="pi pi-trash"
                            actionListener="#{sysParamMB.delSingle}" styleClass="ui-button-danger ml-2 col "
                            update="defDicts">
                            <p:confirm header="#{sms['confirm.title']}" message="#{sms['confirm.message']}"
                                icon="pi pi-exclamation-triangle" />
                        </p:commandButton>
                        <p:commandButton id="delete-multiple-button" value="#{sms['button.delMultiple']}"
                            icon="pi pi-trash" actionListener="#{sysParamMB.delMultiple}"
                            styleClass="ui-button-danger ml-2 col" update="defDicts">
                            <p:confirm header="#{sms['confirm.title']}" message="#{sms['confirm.message']}"
                                icon="pi pi-exclamation-triangle" />
                        </p:commandButton>

                        <p:commandButton id="newObj" icon="pi pi-plus" update="@form" styleClass="ml-2 col"
                            action="#{sysParamMB.newOpt}" />
                        <p:tooltip for="newObj" value="新建对象" showEffect="clip" hideEffect="fold" />
                    </p:toolbarGroup>
                    <p:toolbarGroup align="right" class="grid">


                        <p:commandButton id="refresh" icon="pi pi-refresh" update="@form" styleClass="ml-2 col"
                            onclick="PF('dictsTable').filter()" />
                        <p:tooltip for="refresh" value="刷新列表" showEffect="clip" hideEffect="fold" />
                        <p:commandButton id="filterSwitch"
                            icon="#{c.globalFilterOnly== true? 'pi pi-search-minus': 'pi pi-search-plus'}"
                            update="@form" styleClass="ml-2 col" action="#{sysParamMB.toggleGlobalFilter()}" />
                        <p:tooltip for="filterSwitch" value="搜索条件显示与隐藏" showEffect="clip" hideEffect="fold" />
                        <p:commandButton id="toggler" type="button" icon="pi pi-objects-column" styleClass="ml-2 col" />
                        <p:tooltip for="toggler" value="列显示隐藏设置" showEffect="clip" hideEffect="fold" />
                        <p:columnToggler datasource="defDicts" trigger="toggler">
                            <p:ajax event="toggle" listener="#{sysParamMB.onToggle}" />
                        </p:columnToggler>
                    </p:toolbarGroup>
                </p:toolbar>
            </f:facet>

            <p:column selectionBox="true" style="width:16px;text-align:center" />

            <p:column headerText="ID" sortBy="#{c.id}" filterBy="#{c.id}" visible="false" filterMatchMode="exact">
                #{c.id}
            </p:column>
            <p:column headerText="#{sms['sys.parameter.name']}" sortBy="#{c.name}" filterBy="#{c.name}" visible="true">
                #{c.name}
            </p:column>


            <p:column headerText="#{sms['sys.parameter.value']}" sortBy="#{c.value}" filterBy="#{c.value}"
                visible="true">
                #{c.value}
            </p:column>
            <p:column headerText="#{sms['sys.parameter.key']}" sortBy="#{c.key}" filterBy="#{c.key}" visible="true">
                #{c.key}
            </p:column>


            <p:column headerText="#{sms['sys.parameter.state']}" width="100" sortBy="#{c.state}" filterBy="#{c.state}"
                visible="true" filterMatchMode="equals">

                <f:facet name="filter">
                    <p:selectOneMenu onchange="PF('dictsTable').filter()" styleClass="ui-custom-filter"
                        converter="jakarta.faces.Boolean">
                        <f:selectItem itemLabel="All" itemValue="#{null}" />
                        <f:selectItem itemLabel="#{sms['common.yes']}" itemValue="true" />
                        <f:selectItem itemLabel="#{sms['common.no']}" itemValue="false" />
                    </p:selectOneMenu>
                </f:facet>
                <h:outputText value="#{c.state== true ? sms['common.yes'] : sms['common.no']}" />
            </p:column>


        </p:dataTable>

    </ui:define>
</ui:composition>